package com.dom.stor.dao.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dom.stor.dao.entity.TGoodStandardTbl;
import com.dom.stor.dao.mapper.TGoodStandardTblMapper;
import com.dom.stor.dao.service.ITGoodStandardTblService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * B_商品规格代码表 服务实现类
 * </p>
 *
 * @author xllei
 * @since 2018-11-17
 */
@Service
public class TGoodStandardTblServiceImpl extends ServiceImpl<TGoodStandardTblMapper, TGoodStandardTbl> implements ITGoodStandardTblService {
    @Override
    public Map<Integer, String> getStandardNameList(Integer memCode) {
        List<TGoodStandardTbl> records = getStandardList(memCode);
        return records.stream().collect(Collectors.toMap(TGoodStandardTbl::getStandardCode, entity->{return entity.getStandardName();}));
    }

    private List<TGoodStandardTbl> getStandardList(Integer memCode){
        Wrapper<TGoodStandardTbl> wrapper = new EntityWrapper<>();
        wrapper.eq("mem_code", memCode)
                .orderBy("id");
        return this.selectList(wrapper);
    }
}
